import 'package:flutter/material.dart';
import 'package:flutter_demo/ui/pages/status/event/event_test__widget.dart';
import 'package:flutter_demo/ui/pages/status/inherited/inherited_test_widget.dart';
import 'package:flutter_demo/ui/pages/status/provider/provider_test_widget.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

import 'index.dart';

var tabTitle = [
  "event",
  "inherited",
  "provider",
];

class StatusPage extends GetView<StatusController> {
  static const String routeName = "/StatusPage";
  const StatusPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return DefaultTabController(
        length: tabTitle.length,
        child: Scaffold(
          appBar: AppBar(
            title: buildTabBar(),
            toolbarHeight: 45,
            centerTitle: true,
            elevation: 0,
          ),
          body: buildTabBarView(),
        ));
  }

  Widget buildTabBar() {
    return Row(
      children: [
        SizedBox(
          width: 330.w,
          child: TabBar(
            tabs: tabTitle.map((e) => Tab(text: e)).toList(),
            isScrollable: true,
            indicatorColor: Colors.transparent,
          ),
        )
      ],
    );
  }

  Widget buildTabBarView() {
    return TabBarView(
        children: tabTitle.map((e) {
      if (e == 'event') {
        return const EventTest();
      } else if (e == 'inherited') {
        return InheritedTestWidget();
      } else if (e == 'provider') {
        return ProviderTestWidget();
      } else {
        return Container();
      }
    }).toList());
  }
}
